﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;

namespace ToolsForCMIS
{
    class clsEmailHelper
    {
        public bool SendEmail(string fromAdd,string fromPass, string toAdd,string subject,string content, ref string strErr)
        {
            try
            {
                MailMessage message = new MailMessage();
                SmtpClient smtp = new SmtpClient();

                message.From = new MailAddress(fromAdd);
                message.To.Add(new MailAddress(toAdd));
                message.Subject = "Thông tin chuỗi kết nối đơn vị: "+subject;
                message.Body = content;
                //smtp.Port = 143;
                //smtp.Host = "webmail.evn.vn";
                smtp.Port = 25;
                smtp.Host = "10.1.0.14";
                //smtp.EnableSsl = false;
                //smtp.UseDefaultCredentials = false;
                smtp.Credentials = new NetworkCredential(fromAdd, fromPass);
                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtp.Send(message);
                strErr = "OK";
                return true;
            }
            catch (Exception ex)
            {
                strErr = ex.Message;
                return false;
            }

        }

    }
}
